EXECUTABLE := cae_convertor_v2
INCLUDES:= /home/ubuntu/CeetronSAM_2.5.0_43b625bf/thirdparty/hdf5-1.14.5-linux64/include
LIB_FOLDERS := /home/ubuntu/CeetronSAM_2.5.0_43b625bf/thirdparty/hdf5-1.14.5-linux64/lib
LIB_FOLDERS += /home/ubuntu/CeetronSAM_2.5.0_43b625bf/thirdparty/cgns-4.4.0-linux64/lib
LIBS := -lhdf5_cpp -lhdf5 -lcgns

CC:=g++
CFLAGS:=-c -Wall -O3 -g
CPPFLAGS += $(addprefix -I,$(INCLUDES))
LDFLAGS := $(addprefix -L,$(LIB_FOLDERS)) $(LIBS)
#CPPFLAGS += -MMD

RM-F := rm -f

SRCS := $(wildcard *.cpp)
OBJS := $(patsubst %.cpp,%.o,$(SRCS))
DEPS := $(patsubst %.o,%.d,$(OBJS))
MISSING_DEPS := $(filter-out $(wildcard $(DEPS)),$(DEPS))
MISSING_DEPS_SOURCES := $(wildcard $(patsubst %.d,%.cpp,$(MISSING_DEPS)))

.PHONY : all deps objs clean veryclean rebuild info

all: $(EXECUTABLE)

deps: $(DEPS)

objs: $(OBJS)

clean:
	@$(RM-F) *.o
	@$(RM-F) *.d

veryclean: clean
	@$(RM-F) $(EXECUTABLE)

rebuild: veryclean all

ifneq ($(MISSING_DEPS),)
$(MISSING_DEPS):
	@$(RM-F) $(patsubst %.d,%.o,$@)
endif
-include $(DEPS)
$(EXECUTABLE): $(OBJS)
	#$(CC) -o $(EXECUTABLE) $(OBJS) $(addprefix -L,$(LIB_FOLDERS)) $(addprefix -l,$(LIBS))
	$(CC) -o $(EXECUTABLE) $(OBJS) $(LDFLAGS)
info:
	@echo $(SRC)
	@echo $(OBJS)
	@echo $(DEPS)
	@echo $(MISSING_DEPS)
	@echo $(MISSING_DEPS_SOURCES)


